﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iCollect.Constants;

namespace iCollect.util
{
    class DBUtil
    {
        private static DBUtil dbUtil;
        public static DBUtil getInstance()
        {
            if (dbUtil == null)
            {
                dbUtil = new DBUtil();
            }
            return dbUtil;
        }

        public void writeData()
        {
            string thisYear = DateTime.Today.Year.ToString();
            string dateStr = DateTime.Today.ToShortDateString().Replace("/", "_");
            string dirName = "Device\\" + GlobalConstants.currentDevice +
                "\\正常" + "\\" + thisYear + "\\" + dateStr;
            string fileName;
            // Delete the file if it exists.
            if (!System.IO.Directory.Exists(dirName))
            {
                System.IO.Directory.CreateDirectory(dirName);
            }

            for (int i = 0; i < GlobalConstants.currentData.Keys.Count; i++)
            {

                String key = GlobalConstants.currentData.Keys.ElementAt(i);
                fileName = dirName + "\\" + key;
                //writeChannelData(key, GlobalConstants.currentData[key], fileName);
            }

        }
    }
}
